package com.docker.ywx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.docker.common.annotation.Log;
import com.docker.common.core.controller.BaseController;
import com.docker.common.core.domain.AjaxResult;
import com.docker.common.enums.BusinessType;
import com.docker.ywx.domain.DoctorPrescriptionTemplate;
import com.docker.ywx.service.IDoctorPrescriptionTemplateService;
import com.docker.common.utils.poi.ExcelUtil;
import com.docker.common.core.page.TableDataInfo;

/**
 * 西/成处方模版Controller
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/ywx/template")
public class DoctorPrescriptionTemplateController extends BaseController
{
    @Autowired
    private IDoctorPrescriptionTemplateService doctorPrescriptionTemplateService;

    /**
     * 查询西/成处方模版列表
     */
    @PreAuthorize("@ss.hasPermi('ywx:template:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorPrescriptionTemplate doctorPrescriptionTemplate)
    {
        startPage();
        List<DoctorPrescriptionTemplate> list = doctorPrescriptionTemplateService.selectDoctorPrescriptionTemplateList(doctorPrescriptionTemplate);
        return getDataTable(list);
    }

    /**
     * 导出西/成处方模版列表
     */
    @PreAuthorize("@ss.hasPermi('ywx:template:export')")
    @Log(title = "西/成处方模版", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoctorPrescriptionTemplate doctorPrescriptionTemplate)
    {
        List<DoctorPrescriptionTemplate> list = doctorPrescriptionTemplateService.selectDoctorPrescriptionTemplateList(doctorPrescriptionTemplate);
        ExcelUtil<DoctorPrescriptionTemplate> util = new ExcelUtil<DoctorPrescriptionTemplate>(DoctorPrescriptionTemplate.class);
        util.exportExcel(response, list, "西/成处方模版数据");
    }

    /**
     * 获取西/成处方模版详细信息
     */
    @PreAuthorize("@ss.hasPermi('ywx:template:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doctorPrescriptionTemplateService.selectDoctorPrescriptionTemplateById(id));
    }

    /**
     * 新增西/成处方模版
     */
    @PreAuthorize("@ss.hasPermi('ywx:template:add')")
    @Log(title = "西/成处方模版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorPrescriptionTemplate doctorPrescriptionTemplate)
    {
        return toAjax(doctorPrescriptionTemplateService.insertDoctorPrescriptionTemplate(doctorPrescriptionTemplate));
    }

    /**
     * 修改西/成处方模版
     */
    @PreAuthorize("@ss.hasPermi('ywx:template:edit')")
    @Log(title = "西/成处方模版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorPrescriptionTemplate doctorPrescriptionTemplate)
    {
        return toAjax(doctorPrescriptionTemplateService.updateDoctorPrescriptionTemplate(doctorPrescriptionTemplate));
    }

    /**
     * 删除西/成处方模版
     */
    @PreAuthorize("@ss.hasPermi('ywx:template:remove')")
    @Log(title = "西/成处方模版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorPrescriptionTemplateService.deleteDoctorPrescriptionTemplateByIds(ids));
    }
}
